package net.flyinggroup.webflux.service;

import net.flyinggroup.webflux.repository.FlyingGroupUserRepository;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
public class FlyingGroupUserService implements ReactiveUserDetailsService {
    private final FlyingGroupUserRepository repository;

    public FlyingGroupUserService(FlyingGroupUserRepository repository) {
        this.repository = repository;
    }

    @Override
    public Mono<UserDetails> findByUsername(String username) {
        return repository.findByUsername(username)
                .cast(UserDetails.class);
    }
}
